package com.naiterui.ehp.bs.emr.vo.health;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.emr.exception.ExceptionCodes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @Description 婚育史
 * @Author gongbaoqiang
 * @Date 2020/6/3 5:43 PM
 */
@Data
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("婚育史")
public class MchVO implements Serializable {
    private static final long serialVersionUID = -8187943338851950263L;

    @ApiModelProperty("婚育史")
    private String value;

    @ApiModelProperty("是否有小孩")
    private String hasChild;

    public void validate() throws BusinessException{
        if(StringUtils.isBlank(value)){
            throw new BusinessException(ExceptionCodes.PATIENT_HEALTH_RECORD_MCH);
        }

        if("已婚".equals(value) || "离异".equals(value)){
            if(StringUtils.isBlank(hasChild)){
                throw new BusinessException(ExceptionCodes.PATIENT_HEALTH_RECORD_MCH);
            }
        }
    }
}
